package com.tuanzi.loan.vo.response.family.largeamount;

import com.tuanzi.loan.core.vo.IdentityResponse;
import com.tuanzi.server.loan_base.constant.largeamount.LargeAmountGzhUserType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * User: liangZongXi
 * Create time: 17:36 2019/3/28
 * Description:
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class LoanLargeAmountGzhResponse extends IdentityResponse {

    private Long applyId;
    private String mobNum;
    private String name;
    private Integer sex;  //0-女 1-男
    private Integer loanAmount;
    private Integer userType;
    private String workCity;
    private String houseBuy;
    private String houseLocation;
    private String carBuy;
    private String carNumLocation;
    private String carUseTotalTime;
    private String carPrice;
    private String insurancePrice;
    private String insuranceUseTotalTime;
    private String salaryPayType;
    private String jobCategory;
    private String salaryIncome;
    private String accumulationFund;
    private String socialSecurity;
    private Integer hasCreditCard;
    private Double welidaiAmount;
    private Double jiebeiAmount;
    private String loanCount;
    private Integer appplyCount;
    private Date applyTime;
    private Integer hasRedPacket;
    private Date getRedPacketTime;
    private Integer hasBackSecurities;
    private Date getBackSecuritiesTime;

    public String getMobNum() {
        if(StringUtils.isNotBlank(mobNum)){
            return mobNum.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
        }
        return mobNum;
    }

    public String getName() {
        if(StringUtils.isNotBlank(name)){
            return "*" + name.substring(1);
        }
        return name;
    }

    public String getUserType() {
        if(null != userType){
            LargeAmountGzhUserType userTypeEnum = LargeAmountGzhUserType.getUserTypeEumByOrdinal(userType);
            return null == userTypeEnum ? null : userTypeEnum.getDetail();
        }

        return null;
    }

    public String getHasInsurance(){
        return StringUtils.isBlank(insurancePrice) ? "无" : "有";
    }

    public Boolean isEntrepreneur(){
        return "job_category_entrepreneur".equals(jobCategory);
    }

    public String hasAccumulationFund(){
        return StringUtils.isBlank(accumulationFund) ? "无":"有";
    }

    public String hasSocialSecurity(){
        return StringUtils.isBlank(socialSecurity) ? "无":"有";
    }
}
